/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import domain.Hotelroom;
import domain.RoomImg;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.FileUploadEvent;
import services.impl.HotelRoomServices;

/**
 *
 * @author amega
 */
@ManagedBean(name="hotelRoomBean")
@SessionScoped
public class HotelRoomBean {
    
    @EJB
    private HotelRoomServices hotelRoomServices;
    
    public List<Hotelroom> allHotelRooms;
    
    public Hotelroom selectedRoom;
    
    public Hotelroom newHotelRoom = new Hotelroom();

    public List<RoomImg> listRoom = new ArrayList<RoomImg>();
    
    public String[] typeOfFood = {
            "ОВ, NA", "BB", "HB", "HB+", "FB", "FB+ EXTFB", 
            "Mini all inclusive", "ALL, Al (all inclusive)",
            "Continental Breakfast","English breakfastv",
            "American breakfast","HCAL","UAL UAI"
            };
    public String classification[] = {
            "STD","BDR, BDRM","Superior","studio","family room ","family studio",
            "extra bed ","suite","suite mini ","junior suite","de luxe ","executive suite",
            "business","honeymoon room","connected rooms","duplex","apartment",
            "president","balcony","City view","Beach view","Pool view","Garden view ",
            "Ocean view","Land view","Dune view",
            "Mountain view","Park view","SV (Sea view)","SSV (Side Sea view) ","Inside view",
    };

    public String[] getTypeOfFood() {
        return typeOfFood;
    }

    public void setTypeOfFood(String[] typeOfFood) {
        this.typeOfFood = typeOfFood;
    }

    public String[] getClassification() {
        return classification;
    }

    public void setClassification(String[] classification) {
        this.classification = classification;
    }
    
    
    
    public List<Hotelroom> getAllHotelRooms() {
        allHotelRooms = hotelRoomServices.findAll();
        return allHotelRooms;
    }

    public void setAllHotelRooms(List<Hotelroom> allHotelRooms) {
        this.allHotelRooms = allHotelRooms;
    }

    public Hotelroom getSelectedRoom() {
        return selectedRoom;
    }

    public void setSelectedRoom(Hotelroom selectedRoom) {
        this.selectedRoom = selectedRoom;
    }

    public Hotelroom getNewHotelRoom() {
        return newHotelRoom;
    }

    public void setNewHotelRoom(Hotelroom newHotelRoom) {
        this.newHotelRoom = newHotelRoom;
    }
    
    public void saveHotelRoom() {
       
        hotelRoomServices.create(newHotelRoom);
        newHotelRoom = new Hotelroom();
    }
    
    public void deleteCurentHotelRoom() {
        hotelRoomServices.remove(selectedRoom);
    }
    
    public void addRoomImg(FileUploadEvent event){
        FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");  
        FacesContext.getCurrentInstance().addMessage(null, msg);
        System.out.println("MADE IT INTO FILE UPLOAD !!! : "+event.getFile().getFileName());
    }
    
    public List<Hotelroom> getFreeRoom() {
        
        return hotelRoomServices.findAll();
    }
    
}
